#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<unordered_map>
#include<string>
using namespace std;
string test(string s, string t)
{
    int minleft = -1, minlen = s.size() + 1;
    unordered_map <char, int> hash1;
    int kinds = 0;
    for (auto& x : t)
    {
        hash1[x]++;
        if (hash1[x] == 1) kinds++;
    }
    unordered_map <char, int> hash2;
    for (int left = 0, right = 0, count = 0; right < s.size(); right++)
    {
        char in = s[right];
        hash2[in]++;
        if (hash1[in] && hash1[in] == hash2[in]) count++;
        while (count == kinds)
        {
            if (minlen >= (right - left + 1))
                minleft = left, minlen = right - left + 1;
            char out = s[left];
            left++;
            if (hash1[out] == hash2[out]) count--;
            hash2[out]--;
        }
    }
    if (minleft == -1) return string();
    return s.substr(minleft, minlen);
}
int main()
{
    cout<<test("ADOBECODEBANC", "ABC");
	return 0;
}